package com.example.yin.service.impl;

import com.example.yin.dao.CommentMapper;
import com.example.yin.domain.Comment;
import com.example.yin.domain.Consumer;
import com.example.yin.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService{
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public boolean addComment(Comment comment) {
        return commentMapper.insertSelective(comment) > 0 ? true:false;
    }

    @Override
    public boolean upComment(Comment comment) {
        commentMapper.userUp(comment);
        return commentMapper.upComment(comment) >0 ?true:false;

    }
    public  boolean selectUp(Comment comment){

        return commentMapper.selectUp(comment) >0 ?true:false;
    }
    public  boolean deleteUp(Comment comment){
        commentMapper.userDown(comment);
        return commentMapper.removeCommentUp(comment) >0 ?true:false;
    }
    //    删除评论
    @Override
    public boolean deleteComment(Integer id) {
        return commentMapper.deleteComment(id) >0 ?true:false;
    }

    @Override
    public List<Comment> commentOfSongId(Integer songId)

    {
        return commentMapper.commentOfSongId(songId);
    }

    @Override
    public List<Comment> commentOfSongListId(Integer songListId)
    {
        return commentMapper.commentOfSongListId(songListId);
    }
}
